package avicit.bdp.dds.api.enums;

import avicit.bdp.core.enums.BaseEnum;

/** running status for workflow and task nodes */
public enum ExecuteStatus implements BaseEnum {

  /** status： 1 running 5 stop 6 failure 7 success */
  RUNNING_EXECUTION(1, "运行中"),
  STOP(5, "停止"),
  FAILURE(6, "失败"),
  SUCCESS(7, "成功");

  private final int code;
  private final String descp;

  ExecuteStatus(int code, String descp) {
    this.code = code;
    this.descp = descp;
  }

  @Override
  public int getCode() {
    return code;
  }

  public String getDescp() {
    return descp;
  }

  public static ExecuteStatus of(int status) {
    for (ExecuteStatus es : values()) {
      if (es.getCode() == status) {
        return es;
      }
    }
    throw new IllegalArgumentException("invalid status : " + status);
  }
}
